import java.util.Locale;

public class Palindrome {
    public static void main(String[] args) {

        String s = ".abcd,c      .ba?";
       // String s ="abcdcba";
        char  ch = 0 ;
        for (int i = 0; i < s.length(); i++) {
            ch = s.charAt(i);
        }

        isLegalcharacters(ch);

        System.out.println(isPalindrome(s));
    }
    public static boolean isLegalcharacters( char ch) {
        if (Character.isDigit(ch) || Character.isLetter(ch)) {
            return true;
        }
        return  false;
    }
    public static  boolean isPalindrome(String s) {
        int left = 0;//
        int right = s.length() - 1;
        String str =s.toLowerCase();
        while (left < right) {
           while (left < right && !isLegalcharacters(str.charAt(left))) {
                left++;
            }
            while(left < right && !isLegalcharacters(str.charAt(right))) {
                right--;
            }

            if (str.charAt(left) == str.charAt(right)) {
                left++;
                right--;
            } else {
                return false;
            }
        }
        return true;
    }
}
